#author:hzkey

import tableprint as tp
import sys
import requests
import re

class Colors:
    GREEN       = '\033[32m'
    RED         = '\033[0;31m'
    BLUE        = '\033[*]'
    ORANGE      = '\033[33m'

def check_host(host):
    try:
        print(Colors.ORANGE+"Checking : %s"%host)
        url = 'http://' + host+'/login.rsp'         
        rr= requests.get(url,timeout=8,allow_redirects=False)
        if rr.status_code == 200 and re.findall("GNU rsp/1.0", rr.headers["Server"]):
            print(Colors.GREEN+"[*] CVE-2018-9995 Detection :Url is %s"%url)
            ff=open('result.txt','a+')
            ff.write('%s\n'%(url))
            ff.close()
    except:
        pass

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print(Colors.BLUE+"""Usage: Python3 CVE-2018-9995.py host.txt
host.txt:127.0.0.1:8080 or baidu.com
""")
    if len(sys.argv) >= 2:
        file = open(sys.argv[1])
        for i in file:
            i = i.strip()
            check_host(i)
        file.close()
